package com.sokal.easycare.modules.product.entity.factory;

import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.sokal.easycare.modules.product.entity.brand.ProBrand;
import javax.validation.constraints.NotNull;
import com.sokal.easycare.modules.sys.entity.Area;

import com.sokal.easycare.common.persistence.TreeEntity;

/**
 * 生产厂家Entity
 * @author liliangdong
 * @version 2017-03-12
 */
public class ProFactory extends TreeEntity<ProFactory> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 厂家名称
	private ProFactory parent;		// 厂家
	private String parentIds;		// 父级IDS
	private ProBrand proBrand;		// 所属品牌
	private String url;		// 网址
	private Area area;		// 城市
	private String address;		// 地址
	private String postcode;		// 邮政编码
	private Double longitude;		// 经度
	private Double latitude;		// 纬度
	private String contact;		// 联系人姓名
	private String sex;		// 性别
	private String mobile;		// 移动电话
	private String telephone;		// 联系电话
	private String fax;		// 传真
	private String email;		// 电子邮箱
	private String workTime;		// 工作时间段
	
	public ProFactory() {
		super();
	}

	public ProFactory(String id){
		super(id);
	}

	@Length(min=1, max=100, message="厂家名称长度必须介于 1 和 100 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@JsonBackReference
	public ProFactory getParent() {
		return parent;
	}

	public void setParent(ProFactory parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=1000, message="父级IDS长度必须介于 0 和 1000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@NotNull(message="所属品牌不能为空")
	public ProBrand getProBrand() {
		return proBrand;
	}

	public void setProBrand(ProBrand proBrand) {
		this.proBrand = proBrand;
	}
	
	@Length(min=0, max=100, message="网址长度必须介于 0 和 100 之间")
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	@NotNull(message="城市不能为空")
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}
	
	@Length(min=0, max=200, message="地址长度必须介于 0 和 200 之间")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@Length(min=0, max=10, message="邮政编码长度必须介于 0 和 10 之间")
	public String getPostcode() {
		return postcode;
	}

	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}
	
	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}
	
	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}
	
	@Length(min=1, max=64, message="联系人姓名长度必须介于 1 和 64 之间")
	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}
	
	@Length(min=1, max=1, message="性别长度必须介于 1 和 1 之间")
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Length(min=1, max=20, message="移动电话长度必须介于 1 和 20 之间")
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	@Length(min=0, max=20, message="联系电话长度必须介于 0 和 20 之间")
	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	
	@Length(min=0, max=20, message="传真长度必须介于 0 和 20 之间")
	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}
	
	@Length(min=0, max=30, message="电子邮箱长度必须介于 0 和 30 之间")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	@Length(min=0, max=200, message="工作时间段长度必须介于 0 和 200 之间")
	public String getWorkTime() {
		return workTime;
	}

	public void setWorkTime(String workTime) {
		this.workTime = workTime;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}